import 'package:flutter/material.dart';
import 'package:getx_scaffold/getx_scaffold.dart';
import 'package:oramemo/common/langs/text_key.dart';

enum MembershipStatus {
  active,
  expired,
}

class MembershipRecordCard extends StatelessWidget {
  final String type;
  final String startDate;
  final String endDate;
  final MembershipStatus status;

  const MembershipRecordCard({
    super.key,
    required this.type,
    required this.startDate,
    required this.endDate,
    required this.status,
  });

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: const EdgeInsets.all(16),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(12),
      ),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Text(
                type,
                style: const TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                ),
              ),
              _buildStatusChip(),
            ],
          ),
          const SizedBox(height: 16),
          _buildInfoRow(TextKey.membershipRecordCardStartDate.tr, startDate),
          const SizedBox(height: 8),
          _buildInfoRow(TextKey.membershipRecordCardEndDate.tr, endDate),
        ],
      ),
    );
  }

  Widget _buildStatusChip() {
    return Container(
      padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
      decoration: BoxDecoration(
        color: status == MembershipStatus.active
            ? const Color(0xFFE8FFF3)
            : const Color(0xFFF5F5F5),
        borderRadius: BorderRadius.circular(4),
      ),
      child: Text(
        status == MembershipStatus.active ? TextKey.membershipRecordCardActive.tr : TextKey.membershipRecordCardExpired.tr,
        style: TextStyle(
          color: status == MembershipStatus.active
              ? const Color(0xFF00B578)
              : Colors.black45,
          fontSize: 12,
        ),
      ),
    );
  }

  Widget _buildInfoRow(String label, String value) {
    return Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Text(
          label,
          style: const TextStyle(
            color: Colors.black54,
            fontSize: 14,
          ),
        ),
        Text(
          value,
          style: const TextStyle(
            color: Colors.black87,
            fontSize: 14,
          ),
        ),
      ],
    );
  }
}